package com.sky.mapper;


import com.sky.entity.ShoppingCart;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface ShoppingCartMapper {
    ShoppingCart selectBy(ShoppingCart cart);


    void insert(ShoppingCart cart);

    /**
     * 根据id更新购物车数量
     * @param cart1
     */
    @Update("update shopping_cart set number=#{number} where id = #{id}")
    void update(ShoppingCart cart1);

    @Select("select * from shopping_cart where user_id =#{userId}")
    List<ShoppingCart> list(Long userId);

    /**
     * 清空购物车
     * @param userId
     */
    @Delete("delete from shopping_cart where user_id = #{userId}")
    void clean(Long userId);

    /**
     * 根据购物车商品id删除商品
     * @param id
     */
    @Delete("delete from shopping_cart where id = #{id}")
    void delete(Long id);

    void insertBatch(List<ShoppingCart> shoppingCartList);
}
